Page({
  data: {
    list:[],
    key:"",
    source:null
  },
  onLoad(e) {
    console.log(e);
    
    this.setData({
      source: getCurrentPages()[getCurrentPages().length-2].data.info.Source
    })
    this.getEmp()
  },
  sltback(e) {
    var preview = getCurrentPages()[getCurrentPages().length-2]
    var newinfo = preview.data.info
    var v = e.detail.value;
    var k = ""
    for (const i in this.data.list) {
      if(this.data.list[i].CustomerId == v){
        k = this.data.list[i].CustomerName
      }
    }
    newinfo.RecommendNo = v
    newinfo.RecommendCustomer = {CustomerName:k}
    preview.setData({info: newinfo})
    
    dd.navigateBack()
  },
  getEmp() {
    var _this = this
    if(this.data.source == 4){
      var data = {
        keywords:this.data.key
      }
    }else{
      var data = {
        keywords:this.data.key,
        EnumOp:8
      }
    }
    getApp().req({
      url:"/customer/select",
      data:data,
      cb(res){
        _this.setData({
          list:res.data
        })
      }
    })
  },
  searchKey(e) {
    this.setData({key: e.detail.value})
    this.getEmp()
  },
  closekey() {
     dd.hideKeyboard();
  }
});
